package co.edu.unal.satacredito.database.administration.ejb;

import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;

import javax.ejb.Stateless;

import co.edu.unal.satacredito.database.administration.exceptions.DAOException;
import co.edu.unal.satacredito.database.administration.singleton.SingletonDataStore;
import co.edu.unal.satacredito.database.connection.TransactionDatastoreFactory;
import co.edu.unal.satacredito.database.dao.EventLogMongoDao;
import co.edu.unal.satacredito.database.dao.MachineMongoDao;
import co.edu.unal.satacredito.database.entity.EventLog;
import co.edu.unal.satacredito.database.entity.Machine;

import com.mongodb.MongoException;

/**
 * Session Bean implementation class MonitorDaoEJB
 */
@Stateless
public class EventLogDaoEJB implements EventLogDaoEJBLocal,
		EventLogDaoEJBRemote {

	private EventLogMongoDao daoE;

	/**
	 * Default constructor.
	 * 
	 * @throws DAOException
	 */
	public EventLogDaoEJB() throws DAOException {
		this.daoE = new EventLogMongoDao(SingletonDataStore.getInstance()
				.getDataStore());
	}
	
	public List<EventLog> findEventsByMachine(Machine machine) throws DAOException{
		try {
			return daoE.findByMachine(machine);
		} catch (Exception e) {
			throw new DAOException(e.getMessage());
		}
	}

	public List<EventLog> findEventsByDate(Date initDate, Date endDate)
			throws DAOException {
		try {
			return daoE.findByDate(initDate, endDate);
		} catch (Exception e) {
			throw new DAOException(e.getMessage());
		}
	}

}
